<?php

declare(strict_types=1);
/**
 * This file is part of MoChat.
 * @link     https://mo.chat
 * @document https://mochat.wiki
 * @contact  group@mo.chat
 * @license  https://github.com/mochat-cloud/mochat/blob/master/LICENSE
 */
namespace MoChat\App\WorkContact\Queue;

use Hyperf\AsyncQueue\Driver\DriverFactory;
use Hyperf\AsyncQueue\Driver\DriverInterface;
use MoChat\App\WorkContact\Job\SyncContactByCorpIdJob;
use MoChat\App\WorkContact\Job\SyncContactDetailJob;
use MoChat\App\WorkContact\Job\SyncContactListJob;

/**
 * 根据员工&多个客户wxid同步多个客户.
 */
class SyncContactQueue
{
    /**
     * @var DriverInterface
     */
    protected $driver;

    public function __construct(DriverFactory $driverFactory)
    {
        $this->driver = $driverFactory->get('contact');
    }

    /**
     * 根据企业Id同步客户异步队列.
     *
     * @param array $params 数据
     * @param int $delay 延时时间 单位秒
     */
    public function syncContactByCorpId(array $params, int $delay = 0): bool
    {
        return $this->driver->push(new SyncContactByCorpIdJob($params), $delay);
    }

    /**
     * 根据员工id同步客户异步队列.
     *
     * @param array $params 数据
     * @param int $delay 延时时间 单位秒
     */
    public function syncContactList(array $params, int $delay = 0): bool
    {
        return $this->driver->push(new SyncContactListJob($params), $delay);
    }

    /**
     * 根据员工&单个客户wxid同步单个客户.
     *
     * @param array $params 数据
     * @param int $delay 延时时间 单位秒
     */
    public function syncContactDetail(array $params, int $delay = 0): bool
    {
        return $this->driver->push(new SyncContactDetailJob($params), $delay);
    }
}
